//
//  String+.swift
//  C023_test_basic
//
//  Created by yao_yu on 15/7/17.
//  Copyright © 2015年 yao_yu. All rights reserved.
//

import Foundation


extension String{
    func replace(target:String, withString: String) -> String{
        return self.stringByReplacingOccurrencesOfString(target, withString: withString, options: NSStringCompareOptions(), range: nil)
    }
    
    var trimed:String {
        return self.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
    }
    
    init(_ newValue:AnyObject?) {
        switch newValue {
        case let number as NSNumber:
            self = "\(number)"
        case let string as NSString:
            self = "\(string)"
        case  _ as NSNull:
            self = ""
        default:
            self = ""
            print("未知类型:\(newValue)")
        }
    }
}

